// const express = require('../express');
// const app = express();

// //  /article/:id  /user/:name
// app.get('/article/:id/user/:name',function(req,res){ // 路由中一般不使用next函数
//     console.log(req.params); // /article/1/user/ikki  => {id:1,name:'ikki'}

//     res.end(JSON.stringify(req.params))
// })

// app.listen(3000,function(){
//     console.log(`server start 3000`);
// })


const  pathToRegExp= require('path-to-regexp')
let urlStr = '/article/:id/user/:name';
let keys = []
let reg = pathToRegExp.pathToRegexp(urlStr,keys,true)
console.log(reg); //   /^\/article(?:\/([^\/#\?]+?))\/user(?:\/([^\/#\?]+?))[\/#\?]?$/i
console.log(keys)
// ==>
[
    {
        name: 'id',
        prefix: '/',
        suffix: '',
        pattern: '[^\\/#\\?]+?',
        modifier: ''
    },
    {
        name: 'name',
        prefix: '/',
        suffix: '',
        pattern: '[^\\/#\\?]+?',
        modifier: ''
    }
]